<extend name="Layout::member"/>
<block name="content">
    <div class="layout-content">

        <div class="page-title">会员管理</div>

        <div class="content-top">
            <ul class="top-nav">
                <li class="active"><span>修改信息</span></li>
            </ul>
            <div class="clearfix"></div>
        </div>
        <div class="clearfix"></div>
        <!--content-main start-->
        <div class="container-fluid content-main">
            <div class="row">
                <div class="col-md-12">
                    <div id="tsk" class="ui-tips bg-info" style="display:none">
                        <span class="icon glyphicon glyphicon-info-sign"></span> <span
                            id="ts">提示信息提示信息提示信息提示信息提示信息提示信息。</span>
                    </div>

                    <form class=" form-horizontal" onsubmit="return false">
                        <input type="hidden" value="{$list['id']}" class="js-id"/>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">预约人</label>
                            <div class="col-sm-5">
                                <input type="text" value="{$list['name']}" class="form-control js-name"/>
                                <span class="help-block"></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">手机号码</label>
                            <div class="col-sm-5">
                                <input type="text" value="{$list['mobile']}" class="form-control js-mobile"/>
                                <span class="help-block"></span>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">面积</label>
                            <div class="col-sm-5">
                                <input type="text" class="form-control js-place" value="{$list['place']}"/>
                                <span class="help-block"></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">新旧</label>
                            <div class="col-sm-5">
                                <select class="form-control js-status" name="status">
                                    <option data-status="10" value="10">新</option>
                                    <option data-status="30" value="30">旧</option>
                                </select>
                                <span class="help-block"></span>
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-8">
                                <button onclick="func()" style="margin-left: 90px;width: 150px" type="submit"
                                        class="btn btn-default">保存
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        <!--content-main end-->
    </div>
    <script>
        $(function () {
            $('option[data-status={$list["status"]}]').attr("selected", true);
        })
        function func() {
            var name = $('.js-name').val();
            if (name == '') {
                $('#tsk').css('display', 'block');
                $('#ts').html("预约人不能为空");
                return false;
            }

            var mobile = $('.js-mobile').val();
            if (mobile == '') {
                $('#tsk').css('display', 'block');
                $('#ts').html("手机号码不能为空");
                return false;
            }

            var place = $('.js-place').val();
            if (place == '') {
                $('#tsk').css('display', 'block');
                $('#ts').html("面积不能为空");
                return false;
            }
            var id = $('.js-id').val();
            var status=$('.js-status').val();

            $.ajax({
                type: 'POST',
                url: "{:U('Fast/doUpdate')}",
                data: {
                    'name': name,
                    'mobile':mobile,
                    'place':place,
                    'status':status,
                    'id': id
                },
                dataType: 'json',
                success: function (data) {
                    //alert(data);return false;
                     //console.dir(JSON.parse(data));
                    // return false;
                    if (data == 1) {
                        $('#tsk').css('display', 'block');
                        $('#ts').html('修改成功');
                        setTimeout(function () {
                            location.href = "{:U('Fast/index')}";
                        }, 1000);
                    } else if (data == 2) {
                        $('#tsk').css('display', 'block');
                        $('#ts').html('修改失败');
                    }
                }
            })
        }
    </script>
</block>
